package com.mpgame.common.handler;

import com.mpgame.common.proto.GamePacket;
import com.mpgame.common.utils.Log;

import io.netty.channel.ChannelHandlerContext;

public abstract class BaseHandler {

    protected final String handlerName;

    protected final int priority;

    protected final boolean enabled;


    public BaseHandler(){
        this.handlerName = this.getClass().getSimpleName();
        this.priority = 100;
        this.enabled = true;
        Log.info("初始化处理器：" + handlerName);
    }

    public BaseHandler(String handlerName){
        this.handlerName  = handlerName;
        this.priority = 100;
        this.enabled = true;
        Log.info("初始化处理器：" + handlerName);
    }

    public BaseHandler(String handlerName, int priority, boolean enabled){
        this.handlerName = handlerName;
        this.priority = priority;
        this.enabled  = enabled;
        Log.info("初始化处理器: " + handlerName + ", 优先级: " + priority + ", 启用: " + enabled);
    }

    public boolean isEnabled(){
        return this.enabled;
    }

    public abstract boolean handle(ChannelHandlerContext ctx, GamePacket pkt);
}
